from torchvision.datasets import MNIST
from python_ai.common.xcommon import *
import torch as pt
from torch.utils import data
import numpy as np
import torchvision.transforms as trans
from PIL import Image

np.random.seed(777)
pt.manual_seed(777)
pt.set_printoptions(edgeitems=20)

sep('pt.randint')
xt = pt.randint(256, (4, 10), dtype=pt.uint8)
print('xt', type(xt), xt)

sep('np.randint => ToTensor')
x = np.random.randint(0, 256, (4, 10), dtype=np.uint8)
print('x', type(x), x)
xtrans = trans.ToTensor()(x)
print('xtrans', type(xtrans), xtrans)

sep('PIL.Image.fromarray xt.numpy()')
img = Image.fromarray(xt.numpy(), mode='L')
print('img', type(img), img)
sep('ToTensor')
imgt = trans.ToTensor()(img)
print('imgt', type(imgt), imgt)
